package com.fourcitizens.playas

class CountryException {
	String message
	Country country
}


class CountryService {

    static transactional = true

    Country createCountry(String name) {
		def country = new Country(name : name)
		
		if (!country.save(failOnError : true)) {
			throw new CountryException(message : "Could not create the country", country)
		}
		
		return country
    }
	
	Country getCountry(String name) {
		return Country.findByName(name)
	}
	
	
	Country[] getCountries() {
		return Country.list()
	}
	
	
	
}
